package com.runvp.rest.auth;

import com.runvp.common.annotation.Log;
import com.runvp.common.core.controller.BaseController;
import com.runvp.common.core.domain.AjaxResult;
import com.runvp.common.enums.BusinessType;
import com.runvp.service.auth.service.AlipayAuthService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 小程序登录
 *
 * @author xkk update
 */
@Slf4j
@RestController
@RequestMapping("/app/auth")
public class AlipayAuthController extends BaseController {

    @Autowired
    private AlipayAuthService alipayAuthService;

    /**
     * 登录
     * @param authCode
     */
    @Log(title = "支付宝小程序登录", businessType = BusinessType.INSERT)
    @GetMapping("/login/{authCode}")
    public AjaxResult login(@PathVariable String authCode) throws Exception {
        // 用户登录
        // 获取登录token
        return AjaxResult.success(alipayAuthService.login(authCode));
    }
}
